1. Field of the Invention
The present invention relates to a method and an apparatus for encoding digital signals whereby a transmission side of a system is able to satisfactorily encode digital signals at variable bit rates so as to transmit encoded signals to a receiving portion.
2. Description of Prior Art
When digital video signals, which have great quantities of information, are, for a long time, recorded on a small recording medium having a poor storage capacity, or when digital video signals of the foregoing type are transmitted through a multiplicity of channels in a transmission passage having only a limited capacity, a means is required which is capable of efficiently encoding the digital video signals.
FIG. 1 is a block diagram showing the structure of a system for compressing and encoding video image signals composed of a plurality of images (pictures) and taken as an example of the digital signals. Then, the compressed and encoded video signals are recorded on an optical disk taken as an example of the recording medium.
Referring to FIG. 1, a terminal 200 is supplied with video signal S31, and a terminal 201 is supplied with encoding bit rate Renc with which the video signal S31 is encoded. A rate controller 209 instructs required quantity S35 of bits of the supplied pictures which must be encoded in accordance with the encoding bit rate Renc. The video encoder 202 encodes the supplied pictures in such a manner that the quantity is made to be the required quantity S35 of bits which must be encoded. Actual bit quantity S36 realized attributable to the encoding operation is communicated to a rate controller 209. Encoded bit stream S32 obtained as a result of the compressing and encoding operation performed by the video encoder 202 is supplied to a transmission buffer (hereinafter called an "encoder buffer") 203. The encoder buffer 203 smoothes changes in the generated quantity of codes of each supplied picture to output a bit stream at the predetermined bit rate Renc. Bit stream S33 read from the encoder buffer 203 is supplied to a multiplexer 204. Another encoded bit stream obtained by compressing and encoding, for example, an audio signal, is supplied to the multiplexer 204 although the foregoing fact is omitted from illustration. The multiplexer 204 multiplexes a plurality of the supplied bit streams in a time division manner so that one bit stream is formed. An error correction code is, by an ECC encoder 205, added to the bit stream transmitted from the multiplexer 204, and then the bit stream is transmitted to a modulation circuit 206. The ECC encoder 205 subjects the output of the ECC encoder 205 to a predetermined modulation process, for example, an 8-modulation. An output of the modulation circuit 206 is transmitted to a recording head 207 so that the signal S34 is recorded on the optical disk 208.
When the system shown in FIG. 1 is a portable apparatus, an external shock or the like sometimes makes the recording head 207 to temporarily be impossible to record the signal S34 on the optical disk 208 during the operation of the recording head 207 for recording the signal S34 on the optical disk 208.
In the foregoing case, the operation for reading (transmitting) data S33 from the encoder buffer 203 is interrupted. If supply of data S32 at the bit rate Renc to the encoder buffer 203 is attempted to be continued, the encoder buffer 203 finally overflows. An example of the quantity of bits which share the encoder buffer 203 at the foregoing time is shown in FIG. 2.
The abscissa t of a graph shown in FIG. 2 stands for a lapse of time and axis of ordinate stands for an amount of the quantities of bits of data S32 supplied to the encoder buffer 203 until certain time. The gradient of a line e-f-g of the line graph at time t indicates reading (output) rate Rout with which data S33 is read from the encoder buffer 203. The graph shows an example in which reading (output) of data S33 from the encoder buffer 203 is interrupted at time t=E(n). The vertical distance from the line e-f-g and line a-b-c indicates size BB of the encoder buffer 203. The size BB is a constant value. The vertical distance from line e-d and line p-q indicates size B of a virtual code buffer for use in a rate controlling operation. The size B and the size BB have the relationship satisfying B.ltoreq.BB. The code buffer is included in the encoder buffer 203. The size B of the code buffer is generally the same as the size of a receiving buffer (a decoder buffer).
Symbols A (i) represent an i-th encoded picture and the vertical size of symbols A (i) indicates the quantity of bits of the encoded data, while symbols E (i) represent time at which the i-th encoded picture A (i) is encoded. Pictures are encoded at intervals (that is, E (i+1)-E (i)) of 1/29.97 second in a case of so-called NTSC video signals and at intervals of 1/25 second in a case of so-called PAL video signals.
Changes in the quantity of bits which share the encoder buffer are indicated by regions having diagonal lines between a zigzag line and the line e-f-g. A movement of the zigzag line in the direction of the axis of ordinate indicates a fact that an encoded picture has instantaneously supplied to the encoder buffer. On the other hand, a movement of the zigzag line in the direction of the abscissa indicates a fact that supply of a bit stream to the encoder buffer has been interrupted and a bit stream has been transmitted from the encoder buffer at a bit rate Rout indicated by the gradient of the line e-f-g. That is, picture A (0) is instantaneously supplied to the encoder buffer at time t=E (0) so that the quantity of bits sharing the encoder buffer is enlarged by the quantity of bits of the picture A (0). Then, a bit stream is transmitted from the encoder buffer at bit rate Rout until time t=E (1). Therefore, the quantity of bits sharing the encoder buffer is reduced as time elapses. Bits of picture A (1) are instantaneously supplied to the encoder buffer at time t=E (1) so that the quantity of bits sharing the encoder buffer is enlarged by the quantity of bits of picture A (1). Then, similar operations are performed so that pictures are supplied to the encoder buffer at predetermined intervals. The video encoder determines a required quantity of bits of a next picture to be encoded in such a manner that the zigzag line is placed between the line e-d and the line p-q. Then the video encoder encodes the picture. The required quantity S35 of bits of the picture which must be encoded shown in FIG. 1 is calculated as described above.
Referring to FIG. 2, the encoding operation is normally performed in the period from time t=E (0) to time t=E (n) so that data is transmitted from the encoder buffer at a bit rate which is the same as the encoding bit rate. Transmitted data is recorded on the optical disk.
If supply of the bit stream to the encoder buffer at the bit rate Renc is continued though reading of data from the encoder buffer has been interrupted at time t=E (n), the encoder buffer finally overflows. As a result, the encoded bit stream is lost and any bit stream cannot normally be produced. Thus, there arises a problem in that an image is disordered when the optical disk is reproduced and the obtained signal is reproduced by the decoder portion. That is, when the encoded bit stream has been reproduced by the decoder portion, there arises a problem in that a reproduced image is disordered and frozen.
Even if an arrangement is employed in which the encoding operation is temporarily interrupted before the encoder buffer overflows, any encoded bit stream does not exists in the period of the interruption. Thus, there arises a problem in that reproduced images are discontinuous when the encoded bit stream is reproduced by the decoder portion.
If recording of the signal S34 on the optical disk 208 is temporarily inhibited because of, for example, a shock administered from outside to the recording head 207 shown in FIG. 1, the conventional structure encounters a problem in that the encoding operation cannot satisfactorily be performed because of insufficient control of the encoding bit rate.
When a bit stream of the foregoing type is transmitted by a broadcast or communication arranged, even a system arranged in such a manner that transmission is temporarily inhibited if a state of communication is unsatisfactory and output of a transmission buffer from the encoder is interrupted encounters an overflow of the transmitting buffer occurring because of the foregoing reason. As a result, the encoding bit rate is undesirably lost and thus the receiving portion cannot obtain a normal reproduced image. That is, when the encoded bit stream has been reproduced by the decoder portion, there arises a problem in that a reproduced image is disordered and frozen.